Added a render_icon virtual method.
authorFederico Mena Quintero <federico@ximian.com>
Wed, 19 Nov 2003 17:03:32 +0000 (17:03 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Wed, 19 Nov 2003 17:03:32 +0000 (17:03 +0000)
2003-11-19  Federico Mena Quintero  <federico@ximian.com>

* gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
render_icon virtual method.

* gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.

* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
Implement as a stub for now.

* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
gtk_file_system_render_icon().
(list_icon_data_func): Likewise.
(toolbar_create): Set the toolbar style to icons only.

* gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
Fix doc comments.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooser.c
gtk/gtkfilechooserdefault.c
gtk/gtkfilesystem.c
gtk/gtkfilesystem.h
gtk/gtkfilesystemunix.c

index badaecef92f1920a8d9c4a416ed363244267d518..600a1c2ccdcaaf66ad4e4635c602132a78f0bd15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2003-11-19  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
+       render_icon virtual method.
+
+       * gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
+       Implement as a stub for now.
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
+       gtk_file_system_render_icon().
+       (list_icon_data_func): Likewise.
+       (toolbar_create): Set the toolbar style to icons only.
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
+       Fix doc comments.
+
 Wed Nov 19 02:18:37 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call 
index badaecef92f1920a8d9c4a416ed363244267d518..600a1c2ccdcaaf66ad4e4635c602132a78f0bd15 100644 (file)
@@ -1,3 +1,21 @@
+2003-11-19  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
+       render_icon virtual method.
+
+       * gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
+       Implement as a stub for now.
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
+       gtk_file_system_render_icon().
+       (list_icon_data_func): Likewise.
+       (toolbar_create): Set the toolbar style to icons only.
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
+       Fix doc comments.
+
 Wed Nov 19 02:18:37 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call 
index badaecef92f1920a8d9c4a416ed363244267d518..600a1c2ccdcaaf66ad4e4635c602132a78f0bd15 100644 (file)
@@ -1,3 +1,21 @@
+2003-11-19  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
+       render_icon virtual method.
+
+       * gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
+       Implement as a stub for now.
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
+       gtk_file_system_render_icon().
+       (list_icon_data_func): Likewise.
+       (toolbar_create): Set the toolbar style to icons only.
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
+       Fix doc comments.
+
 Wed Nov 19 02:18:37 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call 
index badaecef92f1920a8d9c4a416ed363244267d518..600a1c2ccdcaaf66ad4e4635c602132a78f0bd15 100644 (file)
@@ -1,3 +1,21 @@
+2003-11-19  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
+       render_icon virtual method.
+
+       * gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
+       Implement as a stub for now.
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
+       gtk_file_system_render_icon().
+       (list_icon_data_func): Likewise.
+       (toolbar_create): Set the toolbar style to icons only.
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
+       Fix doc comments.
+
 Wed Nov 19 02:18:37 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call 
index badaecef92f1920a8d9c4a416ed363244267d518..600a1c2ccdcaaf66ad4e4635c602132a78f0bd15 100644 (file)
@@ -1,3 +1,21 @@
+2003-11-19  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a
+       render_icon virtual method.
+
+       * gtk/gtkfilesystem.c (gtk_file_system_render_icon): New function.
+
+       * gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon):
+       Implement as a stub for now.
+
+       * gtk/gtkfilechooserdefault.c (shortcuts_insert_path): Use
+       gtk_file_system_render_icon().
+       (list_icon_data_func): Likewise.
+       (toolbar_create): Set the toolbar style to icons only.
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_add_shortcut_folder_uri):
+       Fix doc comments.
+
 Wed Nov 19 02:18:37 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Call 
index a0178625e826c3640ef9635fd0cd674f9e16b40b..82842b69b9fdd6cb002aeff00a82a483f82788a8 100644 (file)
@@ -1532,7 +1532,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
 /**
  * gtk_file_chooser_add_shortcut_folder_uri:
  * @chooser: a #GtkFileChooser
- * @folder: URI of the folder to add
+ * @uri: URI of the folder to add
  * @error: location to store error, or %NULL
  * 
  * Adds a folder URI to be displayed with the shortcut folders in a file
index dbf277948da7919bb05ad91491dc0c9f05ccd4a3..16232bc35d05f87bb03c6aec6e76bab1c443b63b 100644 (file)
@@ -139,7 +139,8 @@ enum {
 };
 
 /* Standard icon size */
-#define ICON_SIZE 36
+/* FIXME: maybe this should correspond to the font size in the tree views... */
+#define ICON_SIZE 20
 
 static void gtk_file_chooser_default_class_init   (GtkFileChooserDefaultClass *class);
 static void gtk_file_chooser_default_iface_init   (GtkFileChooserIface        *iface);
@@ -434,7 +435,11 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, GError **err
     return NULL;
 
   parent_folder = gtk_file_system_get_folder (file_system, parent_path,
+#if 0
                                              GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
+#else
+                                             GTK_FILE_INFO_DISPLAY_NAME,
+#endif
                                              error);
   gtk_file_path_free (parent_path);
 
@@ -471,15 +476,22 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
   if (is_root)
     info = gtk_file_system_get_root_info (impl->file_system,
                                          path,
+#if 0
                                          GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
+#else
+                                         GTK_FILE_INFO_DISPLAY_NAME,
+#endif
                                          error);
   else
     info = get_file_info (impl->file_system, path, error);
 
   if (!info)
     return FALSE;
-
+#if 0
   pixbuf = gtk_file_info_render_icon (info, impl->shortcuts_tree, ICON_SIZE);
+#endif
+  /* FIXME: NULL GError */
+  pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
 
   gtk_tree_store_insert (impl->shortcuts_model, &iter, NULL, pos);
   path_copy = gtk_file_path_copy (path);
@@ -715,6 +727,8 @@ static GtkWidget *
 toolbar_create (GtkFileChooserDefault *impl)
 {
   impl->toolbar = gtk_toolbar_new ();
+  gtk_toolbar_set_style (GTK_TOOLBAR (impl->toolbar), GTK_TOOLBAR_ICONS);
+
   impl->up_button = toolbar_add_item (impl, GTK_STOCK_GO_UP, G_CALLBACK (toolbar_up_cb));
 
   return impl->toolbar;
@@ -1585,7 +1599,9 @@ set_list_model (GtkFileChooserDefault *impl)
 
   impl->list_model = _gtk_file_system_model_new (impl->file_system,
                                                 impl->current_folder, 0,
+#if 0
                                                 GTK_FILE_INFO_ICON |
+#endif
                                                 GTK_FILE_INFO_DISPLAY_NAME |
                                                 GTK_FILE_INFO_IS_FOLDER |
                                                 GTK_FILE_INFO_SIZE |
@@ -2395,6 +2411,25 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
                     gpointer           data)
 {
   GtkFileChooserDefault *impl = data;
+  GtkTreeIter child_iter;
+  const GtkFilePath *path;
+  GdkPixbuf *pixbuf;
+
+  gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
+                                                 &child_iter,
+                                                 iter);
+  path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
+
+  /* FIXME: NULL GError */
+  pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
+  g_object_set (cell,
+               "pixbuf", pixbuf,
+               NULL);
+
+  if (pixbuf)
+    g_object_unref (pixbuf);
+               
+#if 0
   const GtkFileInfo *info = get_list_file_info (impl, iter);
 
   if (info)
@@ -2409,6 +2444,7 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
       if (pixbuf)
        g_object_unref (pixbuf);
     }
+#endif
 }
 
 /* Sets a cellrenderer's text, making it bold if the GtkFileInfo is a folder */
index 200a3185c271dab3d22ba1f04918a78af13dcae6..c927029d06f17bc6780b2ee62361d88ea2ec1182 100644 (file)
@@ -31,7 +31,9 @@ struct _GtkFileInfo
   gchar *display_name;
   gchar *display_key;
   gchar *mime_type;
+#if 0
   GtkFileIconType icon_type : 4;
+#endif
   guint is_folder : 1;
   guint is_hidden : 1;
 };
@@ -245,6 +247,7 @@ gtk_file_info_set_size (GtkFileInfo *info,
   info->size = size;
 }
 
+#if 0
 void
 gtk_file_info_set_icon_type  (GtkFileInfo      *info,
                              GtkFileIconType   icon_type)
@@ -406,6 +409,7 @@ gtk_file_info_render_icon (const GtkFileInfo *info,
 
   return get_cached_icon (widget, "gnome-fs-regular", pixel_size);
 }
+#endif
 
 /*****************************************
  *             GtkFileSystem             *
@@ -667,6 +671,21 @@ gtk_file_system_filename_to_path (GtkFileSystem *file_system,
   return GTK_FILE_SYSTEM_GET_IFACE (file_system)->filename_to_path (file_system, filename);
 }
 
+GdkPixbuf *
+gtk_file_system_render_icon (GtkFileSystem      *file_system,
+                            const GtkFilePath  *path,
+                            GtkWidget          *widget,
+                            gint                pixel_size,
+                            GError            **error)
+{
+  g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+  g_return_val_if_fail (path != NULL, NULL);
+  g_return_val_if_fail (widget != NULL, NULL);
+  g_return_val_if_fail (pixel_size > 0, NULL);
+
+  return GTK_FILE_SYSTEM_GET_IFACE (file_system)->render_icon (file_system, path, widget, pixel_size, error);
+}
+
 /**
  * gtk_file_system_add_bookmark:
  * @file_system: a #GtkFileSystem
index 288b8cbef7905b38b124b32f360311c600c3d6bf..e3c061870d772b4a27e91e51ea527f6b7c130b00 100644 (file)
@@ -54,10 +54,13 @@ typedef enum {
   GTK_FILE_INFO_MIME_TYPE         = 1 << 3,
   GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
   GTK_FILE_INFO_SIZE              = 1 << 5,
+#if 0
   GTK_FILE_INFO_ICON              = 1 << 6,
+#endif
   GTK_FILE_INFO_ALL               = (1 << 7) - 1
 } GtkFileInfoType;
 
+#if 0
 /* Icon type, supplemented by MIME type
  */
 typedef enum {
@@ -70,6 +73,7 @@ typedef enum {
   GTK_FILE_ICON_FIFO,
   GTK_FILE_ICON_SOCKET
 } GtkFileIconType;
+#endif
 
 /* GError enumeration for GtkFileSystem
  */
@@ -117,12 +121,14 @@ void                  gtk_file_info_set_modification_time (GtkFileInfo       *in
 gint64                gtk_file_info_get_size              (const GtkFileInfo *info);
 void                  gtk_file_info_set_size              (GtkFileInfo       *info,
                                                           gint64             size);
+#if 0
 void                  gtk_file_info_set_icon_type         (GtkFileInfo       *info,
                                                           GtkFileIconType    icon_type);
 GtkFileIconType       gtk_file_info_get_icon_type         (const GtkFileInfo *info);
 GdkPixbuf *           gtk_file_info_render_icon           (const GtkFileInfo *info,
                                                           GtkWidget         *widget,
                                                           gint               pixel_size);
+#endif
 
 /* The base GtkFileSystem interface
  */
@@ -177,6 +183,14 @@ struct _GtkFileSystemIface
   GtkFilePath *(*filename_to_path) (GtkFileSystem      *file_system,
                                    const gchar        *path);
 
+  /* Icons */
+
+  GdkPixbuf *  (*render_icon)    (GtkFileSystem     *file_system,
+                                 const GtkFilePath *path,
+                                 GtkWidget         *widget,
+                                 gint               pixel_size,
+                                 GError           **error);
+
   /* Bookmarks */
 
   gboolean       (*add_bookmark)           (GtkFileSystem     *file_system,
@@ -232,6 +246,12 @@ GtkFilePath *gtk_file_system_uri_to_path      (GtkFileSystem     *file_system,
 GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem     *file_system,
                                               const gchar       *filename);
 
+GdkPixbuf   *gtk_file_system_render_icon   (GtkFileSystem      *file_system,
+                                           const GtkFilePath  *path,
+                                           GtkWidget          *widget,
+                                           gint                pixel_size,
+                                           GError            **error);
+
 gboolean gtk_file_system_add_bookmark    (GtkFileSystem     *file_system,
                                          const GtkFilePath *path,
                                          GError           **error);
index a5010fbf366e05c3fa99619c98a0e548729c8d01..d0a1924c4690a05eb9be74f2d22bdf5e9d9fc869 100644 (file)
@@ -114,6 +114,12 @@ static GtkFilePath *gtk_file_system_unix_uri_to_path      (GtkFileSystem     *fi
 static GtkFilePath *gtk_file_system_unix_filename_to_path (GtkFileSystem     *file_system,
                                                           const gchar       *filename);
 
+static GdkPixbuf *gtk_file_system_unix_render_icon (GtkFileSystem     *file_system,
+                                                   const GtkFilePath *path,
+                                                   GtkWidget         *widget,
+                                                   gint               pixel_size,
+                                                   GError           **error);
+
 static gboolean gtk_file_system_unix_add_bookmark    (GtkFileSystem     *file_system,
                                                      const GtkFilePath *path,
                                                      GError           **error);
@@ -223,6 +229,7 @@ gtk_file_system_unix_iface_init   (GtkFileSystemIface *iface)
   iface->path_to_filename = gtk_file_system_unix_path_to_filename;
   iface->uri_to_path = gtk_file_system_unix_uri_to_path;
   iface->filename_to_path = gtk_file_system_unix_filename_to_path;
+  iface->render_icon = gtk_file_system_unix_render_icon;
   iface->add_bookmark = gtk_file_system_unix_add_bookmark;
   iface->remove_bookmark = gtk_file_system_unix_remove_bookmark;
   iface->list_bookmarks = gtk_file_system_unix_list_bookmarks;
@@ -545,6 +552,21 @@ gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
   return gtk_file_path_new_dup (filename);
 }
 
+static GdkPixbuf *
+gtk_file_system_unix_render_icon (GtkFileSystem     *file_system,
+                                 const GtkFilePath *path,
+                                 GtkWidget         *widget,
+                                 gint               pixel_size,
+                                 GError           **error)
+{
+  /* FIXME: Implement this */
+  g_set_error (error,
+              GTK_FILE_SYSTEM_ERROR,
+              GTK_FILE_SYSTEM_ERROR_FAILED,
+              _("This file system does not support icons"));
+  return NULL;
+}
+
 static gboolean
 gtk_file_system_unix_add_bookmark (GtkFileSystem     *file_system,
                                   const GtkFilePath *path,
@@ -726,7 +748,9 @@ filename_get_info (const gchar     *filename,
                   GError         **error)
 {
   GtkFileInfo *info;
+#if 0
   GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
+#endif
   struct stat statbuf;
   
   /* If stat fails, try to fall back to lstat to catch broken links
@@ -784,6 +808,7 @@ filename_get_info (const gchar     *filename,
       gtk_file_info_set_is_folder (info, S_ISDIR (statbuf.st_mode));
    }
 
+#if 0
   if (types & GTK_FILE_INFO_ICON)
     {
       if (S_ISBLK (statbuf.st_mode))
@@ -804,16 +829,21 @@ filename_get_info (const gchar     *filename,
 
   if ((types & GTK_FILE_INFO_MIME_TYPE) ||
       ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR))
+#else
+  if (types & GTK_FILE_INFO_MIME_TYPE)
+#endif
     {
       const char *mime_type = xdg_mime_get_mime_type_for_file (filename);
       gtk_file_info_set_mime_type (info, mime_type);
 
+#if 0
       if ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR &&
          (statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) &&
          (strcmp (mime_type, XDG_MIME_TYPE_UNKNOWN) == 0 ||
           strcmp (mime_type, "application/x-executable") == 0 ||
           strcmp (mime_type, "application/x-shellscript") == 0))
        gtk_file_info_set_icon_type (info, GTK_FILE_ICON_EXECUTABLE);
+#endif
     }
 
   if (types & GTK_FILE_INFO_MODIFICATION_TIME)